const { queryDatabase } = require('../queue-client');

// 获取无货货位（不考虑任务状态）
async function getEmptySlots() {
  try {
    console.log('开始执行无货货位查询');
    
    const sql = `
      SELECT * 
      FROM storage_slots 
      WHERE has_goods = 0
      ORDER BY row, column, layer
    `;
    
    const rows = await queryDatabase(sql);
    console.log(`查询到 ${rows.length} 个无货货位`);
    return rows;
  } catch (error) {
    console.error('查询无货货位失败:', error);
    throw error;
  }
}

module.exports = {
  getEmptySlots
};